package com.tjsoft.demo.webChat.util;
import java.util.Random;
import org.apache.commons.httpclient.util.DateUtil;
public class IDFactory {
	
	/**
	 * 主键ID 根据时间格式与随机数组成的number构造id
	 * 
	 * @return Long 
	 */
	public static String getId() {
		StringBuffer sb = new StringBuffer();// 字串对象
		Random random = new Random();// 随机对象
		
		sb.append(DateUtil.formatDate(new java.util.Date(),"yyyyMMddHHmmss")); // 格式化时间类型
		for (int i = 0; i < 5; i++) {// 循环产生随机数字串
			sb.append(random.nextInt(10));
		}
		return sb.toString();
	}

}
